package simplefactory

import "fmt"

//API is interface
type API interface {
	Say(name string) string
}

//NewApi return Api interface by type
func NewAPI(t int) API {
	if t == 1 {
		return &hiApi{}
	} else if t == 2 {
		return &helloApi{}
	}
	return nil
}

//hiApi  is one of api imp
type hiApi struct{}

func (*hiApi) Say(name string) string {
	return fmt.Sprintf("Hi, %s", name)
}

type helloApi struct{}

func (*helloApi) Say(name string) string {
	return fmt.Sprintf("Hello, %s", name)
}
